home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 43
/
Mac Magazin and MacEasy Magazine CD - Issue 43.iso
/
Software
/
Mobiles Büro
/
Newton
/
Newton Entwickler
/
Newt Development Env. 3.4 ƒ
/
applic0.nwt
next >
Wrap
Text File
|
1998-01-25
|
5KB
|
185 lines
Notes
{labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business. remove viewFont for current Styles default
//ERASE! in order to erase existing entries in this folder first
applic0.nwt -- Sloup format
25 Jan 1998
Copyright 1994-98 S. Weyer. All Rights Reserved Worldwide.
A simple introduction to creating applications with Newt. This is a variation
on a version described in article "Building Native Newton Applications with
Newt" in PIE Developers, July 1994.
corresponds to code in NewtATut 1.5 tutorial
To minimize text entry, use the Sloup utility and a terminal emulator to
transfer this text file as paragraphs in the Notepad. The folder in 2nd line
is currently set on nil (Unfiled); select same folder in Newt to load.
Tap Expr button, select expression :doObj('add, 'MyApp).
Tap Eval, select MyApp, then select each subsequent object in list
to create application incrementally. Or, select :doObj('buildCO, 'MyApp)
to build entire application in one command.
This version of app supports Rotate on NOS 2.x, so you can build application
in Landscape orientation, or Rotate after application has been created/saved.
----------
MyApp
//:doObj('buildCO,'MyApp)
//:doObj('add,'MyApp)
{_proto: protoApp,
viewBounds: nil, // compute in viewSetupFormScript
title: "Hello World",
viewSetupFormScript: func()
begin
local ap := GetAppParams(); // use full (current) screen
self.viewBounds := RelBounds(
ap.AppAreaLeft, ap.AppAreaTop,
ap.AppAreaWidth, ap.AppAreaHeight);
inherited:?viewSetupFormScript();
end,
ReorientToScreen: func() // support Rotate for NOS 2.x
begin
:SyncView();
:RedoChildren();
end,
helpBook: :helpBookTemplate(),
helpView: NIL,
viewQuitScript: func()
begin
if helpView then helpView:close();
helpView := NIL;
inherited:?viewQuitscript();
end,
_package: {
shortTitle: "Hello", // a shorter title for Extras if you install
},
}
----------
MyApp+button
{_proto: protoTextButton,
viewBounds: RelBounds(100,100,40,16),
text: "About",
buttonClickScript: func()
if float exists
then float:open()
else PlaySound(@102), // ROM_funbeep
}
----------
MyApp+float
{_proto: protoFloatNGo, // an empty floating view to contain about text
viewBounds: RelBounds(20,120,150,100),
}
----------
MyApp.float+aboutText
{_proto: protoAboutText,
text:
"This demo created by
<A HREF=\"mailto:" &
:GetUserConfig('mailAccount) & "\">" &
:GetUserConfig('name) & "</A>
with the help of Newt,
the lizard wizard.
<A HREF=\"http://members.bellatlantic.net/~sweyer/newton/index.htm\">Steve's releases page</A>",
}
----------
MyApp.myInputProto
{_proto: protoInputLine,
text: "",
value: 0,
viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed,
getTextValue: func() // from text, set number value (used by total)
begin
self.value := StringToNumber(text);
if not value then value := 0;
end,
viewChangedScript: func(slot,view)
if slot='text
then begin
:getTextValue();
if total exists then total:update();
end,
viewSetupFormScript: func()
begin
self.text := Clone(text);
:getTextValue();
inherited:?viewSetupFormScript();
end,
}
----------
MyApp+num1
{_proto: myInputProto,
viewBounds: RelBounds(130,20,100,20),
}
----------
MyApp+num2
{_proto: myInputProto,
viewBounds: RelBounds(130,45,100,20),
}
----------
MyApp+total
{_proto: protoStaticText,
viewBounds: RelBounds(130,80,100,16),
text: "Total", // initial text
numVars: ['num1, 'num2],
getValueText: func() // return text from summing field values
begin
local tot := 0, field;
foreach field in numVars // add up num1.value + num2.value etc.
do tot := tot + GetVariable(self,field).value;
if round exists and round.viewValue
then tot := RIntToL(tot);
NumberStr(tot); // return string
end,
update: func()
SetValue(self,'text,:getValueText()),
viewSetupFormScript: func()
begin
self.text := :getValueText();
inherited:?viewSeutpFormScript();
end,
}
----------
MyApp+round
{_proto: protoCheckbox,
viewBounds: RelBounds(20,78,50,16),
text: "Round?",
valueChanged: func()
if total exists then total:update(),
}
---------
MyApp+info
{_proto: protoInfoButton,
viewJustify: 134, /* vjCenterH + vjCenterV + vjParentBottomV */
viewBounds: RelBounds(25,-18,13,13),
DoInfoAbout: func()
if float exists
then float:open()
else PlaySound(@102), /* ROM_funbeep */
DoInfoHelp: func()
begin
local ttim := GetRoot().tinyTim;
if not helpView
then helpView := BuildContext({
_proto: ttim._proto,
bookRef: helpBook});
ttim:close();
helpView:openManual(helpBook);
end,
}
----------
MyApp.helpBook+page1
.subject 1
Describe Hello World
.story
Read the NewtATut tutorial.
----------
MyApp.helpBook+page2
.subject 1
Use Hello World
.story
Very simple -- just write in some numbers.
----------
BYE!